package org.yty.travelagencyredis.service.impl;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.yty.travelagencyredis.Dao.MessageDao;
import org.yty.travelagencyredis.model.DTO.HistoryMessageQueryDTO;
import org.yty.travelagencyredis.model.Entity.Message;
import org.yty.travelagencyredis.service.MessageService;

import java.util.List;

@Service
@RequiredArgsConstructor
public class MessageServiceImpl implements MessageService {
    private final MessageDao messageDao;

    @Override
    public List<Message> getMessages(Long senderId, Long receiverId) {
        return this.messageDao.getMessages(senderId, receiverId);
    }

    @Override
    public List<Message> getHistoryMessages(HistoryMessageQueryDTO historyMessageQueryDTO) {
        return this.messageDao.getHistoryMessages(historyMessageQueryDTO);
    }

    @Override
    public void save(Message message) {
        this.messageDao.insert(message);
    }
}
